package com.xing.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xing.dao.SubsidiaryDao;
import com.xing.model.SubsidiaryInfo;

@Service
public class SubsidiaryService {

	@Resource
	private SubsidiaryDao dao;
	
	public void setDao(SubsidiaryDao dao) {
		this.dao = dao;
	}

	public SubsidiaryInfo getSubsidiary(int id) {
		
		return dao.getSubsidiaryInfo(id);
	}

	public void addSubsidiary(SubsidiaryInfo info) {
		
		dao.addSubsidiary(info);
	}
	
	public void updateSubsidiary(SubsidiaryInfo info) {
		
		dao.updateSubsidiary(info);
	}
	
	public void deleteSubsidiary(String idStr) {
		
		String[] arr = idStr.split(",");
		List<Integer> idList = new ArrayList<Integer>();
		for (String tmp : arr) {
			idList.add(Integer.parseInt(tmp));
		}
		
		dao.deleteSubsidiary(idList);
	}
	
	public List<SubsidiaryInfo> getList() {
		
		return dao.getList();
	}
	
	public Map<String, Object> getListAndCount(List<String> conditionList, int page, int pageRow) {
		
		return dao.getListAndCount(conditionList, page, pageRow);
	}
}
